// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import {Group,Cell,Divider,ConfigPlugin,BusPlugin,DevicePlugin,ToastPlugin,AlertPlugin,ConfirmPlugin,LoadingPlugin} from 'vux';

// 组件化 
Vue.component('group',Group);
Vue.component('cell',Cell);
Vue.component('divider',Divider);
Vue.use(ConfigPlugin,{}) // vux global config (vux全局配置)
// plugins
Vue.use(DevicePlugin)
Vue.use(ToastPlugin)
Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)
Vue.use(LoadingPlugin)
Vue.use(BusPlugin)

Vue.config.productionTip = false

const FastClick = require('fastclick');
FastClick.attach(document.body);

import Http from "@/utils/http";
Vue.prototype.$Http = Http;

// rem自适应
(function (doc, win) {
  var docEl = doc.documentElement;
  var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
  var recalc = function () {
    var clientWidth = docEl.clientWidth;
    if (!clientWidth) return;
    if (clientWidth > 640) clientWidth = 640;
    docEl.style.fontSize = clientWidth / 23.4375 + 'px';
  };
  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);


router.afterEach(function (to) {
  // 从路由的元信息中获取 title 属性
  if (to.meta.title) {
    document.title = to.meta.title || 'title';
  }
})
// js交互
require("@/utils/jsBridge.js");

import "../static/css/global.css";

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
